#ifndef BIT_WIN_ROW_TEXT_H
#define BIT_WIN_ROW_TEXT_H


#include <QMetaType>
#include <QSharedDataPointer>


// Forward declarations

class QString;
class QStringList;


namespace BitWin
{


// Forward declarations

class BitRange;

// BitWin table row text class.
// Provides unified text-like protocol for different data types.
// NB!
//      1. The client code should NOT instanciate
//          this class explicitly, use PRowTest class instead!
//          PRowText instanciate some of it's childs.
//      2. This is the protocol class, with abstract key methods.
class RowText;


// RowText smart pointer class
class PRowText
{
    // Data pointer
    QExplicitlySharedDataPointer<const RowText> _pointee;

public:

    // Default constructor is required by QVariant.
    // Creates null (no-data) text.
    PRowText();
    // Work constructor
    explicit PRowText(const RowText* p);

    // Static member, providing a ramp (i.e. RowText
    // generating text representation for integer numbers sequence
    // from 1 to infinity) smart pointer.
    static PRowText RAMP;

    // Pointee accessor
    const RowText* const operator->() const;

    // For test purposes only!
    bool operator==(const BitWin::PRowText& rhs) const;
};


// RowText itself
class RowText: public QSharedData
{
    // Declared, but not implemented
    RowText& operator=(const RowText&);
    RowText(const RowText&);

public:

    RowText();
    virtual ~RowText();

    // Key virtual methods:
    // get the number of data items, get the data item by index.
    virtual int size() const =0;
    virtual QString at(int) const =0;

    // Key non-virtual methods:
    // get data substring, get data visible in the given range only.
    PRowText mid(const BitRange& range) const;
    PRowText viewIn(const BitRange& range) const;
};


} // BitWin namespace end


Q_DECLARE_METATYPE(BitWin::PRowText)


#endif
